angular.module("NTApp").controller('ShareDeviceCtrl', function($stateParams, WXService) {

  var sd = this;
  // var physicalDeviceId = 'ACCF23DAADD8';
  var deviceId = $stateParams.idStr.split('-')[0];
  var pId = $stateParams.idStr.split('-')[1];
  var openId = WXService.getWeChat().openId;

  WXService.getShareCode(deviceId, pId, openId).then(function(result) {
    return result.shareCode;
  }).then(function(shareCode) {
    return openId + '-' + pId + '-' + deviceId + '-' + shareCode;
  }).then(function(url) {
    qrcode.makeCode(url);
  })

  qrcode = new QRCode(document.getElementById("qrcode"), {
    width: 200,
    height: 200
  });

  sd.back = function() {
    history.back();
  }
});
